package ${escapeKotlinIdentifiers(packageName)}

import com.lib.common.base.mvvm.CommonViewModelActivity
import androidx.databinding.DataBindingUtil
import android.os.Bundle
import com.lib.framework.entity.Event
import com.lib.framework.manager.LogManager

<#if applicationPackage??>
import ${applicationPackage}.R
import ${applicationPackage}.databinding.${databindingName}
</#if>

/**
 * Copyright (C), 2019-2020
 * FileName: ${activityClass}
 * Author: 
 * Date: 2020-01-01 00:00
 * Description: XXX 页面
 * History: 
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */
class ${activityClass} : CommonViewModelActivity<${viewModelClass}>() {

    companion object {

        /**
         * 发给 activity 的事件
         */
        const val EVENT_XXX = 1 // XXX 事件
    }

<#if generateLayout>
	private var mDataBinding: ${databindingName}? = null
</#if>

    override fun getViewModelClass() = ${viewModelClass}::class.java

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
<#if generateLayout>
        mDataBinding = DataBindingUtil.setContentView(this, R.layout.${layoutName})
        mDataBinding?.viewModel = mViewModel
</#if>

        initView()
    }

    /**
     * 初始化视图
     */
    private fun initView() {

    }

    override fun dealEvent(event: Event?): Boolean {
        // 处理 viewModel 发送过来的事件
        when (event?.code) {
            EVENT_XXX -> {
                val extraObj = event.extraObj
                if (extraObj is String) {
                    LogManager.i(mTag, "XXX 事件 的额外参数 extraObj = $extraObj")
                }
                return true
            }
        }

        return super.dealEvent(event)
    }
}
